package com.example.test.启动线程;

import java.util.concurrent.*;

public class Callable3 {

    public static void main(String[] args) {

        ExecutorService executorService = Executors.newSingleThreadExecutor();
        FutureTask<String> task = new FutureTask<>(() -> {
            System.out.println("是否执行");
            return "嘿嘿嘿";
        });
        Future<?> submit = executorService.submit(task);//这样写执行的是FutureTask非FutureTask中的Callable

        Future<?> submit2 = executorService.submit(new Callable<String>() {
                               @Override
                               public String call() {
                                   return "heiii";
                               }
                           }
        );
        try {
            System.out.println(submit.get());// 为什么是null
            System.out.println(submit2.get());
//            String msg = (String) task.get();
//            System.out.println(msg);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

//        Thread thread1 = Thread.currentThread();
//        System.out.println(thread1);
    }


}
